*Factors
summ ELF_school Tribes_neighbourhood Tribes_school
factor ELF_school Tribes_neighbourhood Tribes_school, pcf
predict Div_exposure
label variable Div_exposure "Diversity exposure"

summ Ethnic_Lazier Ethnic_equally_smart Ethnic_more_violent Ethnic_equally_honest
factor Ethnic_Lazier Ethnic_equally_smart Ethnic_more_violent Ethnic_equally_honest, pcf
predict Stereotyping
label variable Stereotyping "Stereotype rejection"

summ Ethnic_teacher Ethnic_boss Ethnic_marriage Ethnic_vote
factor Ethnic_teacher Ethnic_boss Ethnic_marriage Ethnic_vote, pcf
predict factor_distance
gen SocialDistance = -1*factor_distance
label variable SocialDistance "Reduced social distance"

summ Hear_politics_home Hear_politics_outside Talk_politics_home Talk_politics_friends Talk_politics_school
factor Hear_politics_home Hear_politics_outside Talk_politics_home Talk_politics_friends Talk_politics_school, pcf
predict Pol_exposure
label variable Pol_exposure "Political exposure"

summ Father_education Mother_education Private_school Books Computer_Ipad
factor Father_education Mother_education Private_school Books Computer_Ipad, pcf
predict SES
label variable SES "SES"

// Institutional trust
summ Trust_President_real Trust_Lagos_Government_real Trust_Army_real Trust_Police_real Trust_parties_real
factor Trust_President_real Trust_Lagos_Government_real Trust_Army_real Trust_Police_real Trust_parties_real, pcf
predict instit_trust
pwcorr instit_trust Trust_President Trust_Lagos_Government Trust_Army Trust_Police Trust_parties

*standardization
// ssc install center
center Friends_ethnic, standardize
label variable c_Friends_ethnic "cross-group friendship"
center Trust_people_rescaled Trust_own_tribe_rescaled Trust_other_tribe_rescaled trust_outvsingroup, standardize
center Current_living_conditions Living_compared Age, standardize
center ELF_school Tribes_neighbourhood Tribes_school, standardize
center Friends_religion Trust_other_rel_rescaled Trust_own_rel_rescaled, standardize

*descriptives
summ Stereotyping SocialDistance c_Trust_other_tribe_rescaled c_Trust_own_tribe_rescaled  c_trust_outvsingroup c_Trust_people_rescaled instit_trust
summ Div_exposure c_Friends_ethnic Pol_exposure
summ SES c_Current_living_conditions c_Living_compared
summ Igbo Hausa_Fulani Other_Ethnicity Mixed_Ethnicity
summ c_Age Female

*regression analyses
xtmixed Stereotyping c.Div_exposure SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity Mixed_Ethnicity Female || School_ID:, variance
estimates store A1
xtmixed Stereotyping c.Div_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
estimates store A2
xtmixed Stereotyping c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity   Mixed_Ethnicity Female || School_ID:, variance
estimates store A3

xtmixed SocialDistance c.Div_exposure SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity Mixed_Ethnicity Female || School_ID:, variance
estimates store B1
xtmixed SocialDistance c.Div_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
estimates store B2
xtmixed SocialDistance c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity   Mixed_Ethnicity Female || School_ID:, variance
estimates store B3

xtmixed c_Trust_other_tribe_rescaled c.Div_exposure SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity Mixed_Ethnicity Female || School_ID:, variance
estimates store C1
xtmixed c_Trust_other_tribe_rescaled c.Div_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
estimates store C2
xtmixed c_Trust_other_tribe_rescaled c.Div_exposure##c.c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
estimates store C3
xtmixed c_Trust_other_tribe_rescaled c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity   Mixed_Ethnicity Female || School_ID:, variance
estimates store C4

xtmixed c_Trust_own_tribe_rescaled c.Div_exposure SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity Mixed_Ethnicity Female || School_ID:, variance
estimates store D1
xtmixed c_Trust_own_tribe_rescaled c.Div_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
estimates store D2
xtmixed c_Trust_own_tribe_rescaled c.Div_exposure##c.c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
estimates store D3
xtmixed c_Trust_own_tribe_rescaled c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity   Mixed_Ethnicity Female || School_ID:, variance
estimates store D4

xtmixed c_Trust_people_rescaled c.Div_exposure SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity Mixed_Ethnicity Female || School_ID:, variance
estimates store E1
xtmixed c_Trust_people_rescaled c.Div_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
estimates store E2
xtmixed c_Trust_people_rescaled c.Div_exposure##c.c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
estimates store E3
xtmixed c_Trust_people_rescaled c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity   Mixed_Ethnicity Female || School_ID:, variance
estimates store E4

xtmixed c_trust_outvsingroup c.Div_exposure SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity Mixed_Ethnicity Female || School_ID:, variance
xtmixed c_trust_outvsingroup c.Div_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
xtmixed c_trust_outvsingroup c.Div_exposure##c.c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
xtmixed c_trust_outvsingroup c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity   Mixed_Ethnicity Female || School_ID:, variance

xtmixed instit_trust c.Div_exposure SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity Mixed_Ethnicity Female || School_ID:, variance
xtmixed instit_trust c.Div_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
xtmixed instit_trust c.Div_exposure##c.c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
xtmixed instit_trust c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity   Mixed_Ethnicity Female || School_ID:, variance

*figures main papers
// figure 2
**# Bookmark #2
set scheme s1mono
coefplot A1, bylabel(Rejection Stereotypes) keep(Div_exposure) ///
|| B1, bylabel (Reduced Social Distance) keep(Div_exposure) ///
|| C1, bylabel (Outgroup trust) keep(Div_exposure) ///
|| D1, bylabel (Ingroup trust)keep (Div_exposure) ///
|| E1, bylabel (General trust) keep(Div_exposure) ///
bycoefs byopts(xrescale) xline(0) subtitle("Exposure to diversity",size(small)) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)

coefplot A2, bylabel(Rejection Stereotypes) keep(Div_exposure c_Friends_ethnic) ///
|| B2, bylabel (Reduced Social Distance) keep(Div_exposure c_Friends_ethnic) ///
|| C2, bylabel (Outgroup trust) keep(Div_exposure c_Friends_ethnic) ///
|| D2, bylabel (Ingroup trust)keep (Div_exposure c_Friends_ethnic) ///
|| E2, bylabel (General trust) keep(Div_exposure c_Friends_ethnic) ///
bycoefs  xline(0) subtitle(,size(small)) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)

coefplot C3, bylabel (Outgroup trust) drop(SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female _cons) ///
|| D3, bylabel (Ingroup trust) drop(SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female _cons)  ///
|| E3, bylabel (General trust) drop(SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female _cons)  ///
bycoefs xline(0) subtitle(,size(small)) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)

coefplot A3, bylabel(Rejection Stereotypes) drop(SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female _cons) ///
|| B3, bylabel (Reduced Social Distance) drop(SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female _cons) ///
|| C4, bylabel (Outgroup trust) drop(SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female _cons) ///
|| D4, bylabel (Ingroup trust) drop(SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female _cons) ///
|| E4, bylabel (General trust) drop(SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female _cons) ///
bycoefs  xline(0) subtitle(,size(small)) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)

//findit mcp

xtmixed c_Trust_people_rescaled c.Div_exposure##c.c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female || School_ID:, variance
mcp  Div_exposure c_Friends_ethnic, at1(-1.5 (0.5) 1.5) at2(-1 0 +1) plotopts(scheme(sj)) show

xtmixed SocialDistance c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity   Mixed_Ethnicity Female || School_ID:, variance
mcp  Div_exposure Pol_exposure, at1(-1.5 (0.5) 1.5) at2(-1 0 +1) plotopts(scheme(sj)) show

xtmixed c_Trust_people_rescaled c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity   Mixed_Ethnicity Female || School_ID:, variance
mcp Div_exposure Pol_exposure, at1(-1.5 (0.5) 1.5) at2(-1 0 +1) plotopts(scheme(sj)) show

* friendship and group interactions
xtmixed Stereotyping c.Div_exposure  SES Current_living_conditions Living_compared Age Igbo##c.c_Friends_ethnic Hausa_Fulani##c.c_Friends_ethnic Other_Ethnicity##c.c_Friends_ethnic  Mixed_Ethnicity Female || School_ID:, variance
xtmixed SocialDistance c.Div_exposure  SES Current_living_conditions Living_compared Age Igbo##c.c_Friends_ethnic Hausa_Fulani##c.c_Friends_ethnic Other_Ethnicity##c.c_Friends_ethnic  Mixed_Ethnicity Female || School_ID:, variance
xtmixed c_Trust_other_tribe_rescaled c.Div_exposure  SES Current_living_conditions Living_compared Age Igbo##c.c_Friends_ethnic Hausa_Fulani##c.c_Friends_ethnic Other_Ethnicity##c.c_Friends_ethnic  Mixed_Ethnicity Female || School_ID:, variance
xtmixed c_Trust_own_tribe_rescaled c.Div_exposure  SES Current_living_conditions Living_compared Age Igbo##c.c_Friends_ethnic Hausa_Fulani##c.c_Friends_ethnic Other_Ethnicity##c.c_Friends_ethnic  Mixed_Ethnicity Female || School_ID:, variance
xtmixed c_Trust_people_rescaled c.Div_exposure  SES Current_living_conditions Living_compared Age Igbo##c.c_Friends_ethnic Hausa_Fulani##c.c_Friends_ethnic Other_Ethnicity##c.c_Friends_ethnic  Mixed_Ethnicity Female || School_ID:, variance


*effect sizes
xtmixed Stereotyping|| School_ID:, variance
regress Stereotyping c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity   Mixed_Ethnicity Female 
estat esize

xtmixed SocialDistance || School_ID:, variance
regress SocialDistance c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity    Mixed_Ethnicity Female 
estat esize

xtmixed c_Trust_other_tribe_rescaled  || School_ID:, variance
regress c_Trust_other_tribe_rescaled c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female 
estat esize

xtmixed c_Trust_own_tribe_rescaled  || School_ID:, variance
regress c_Trust_own_tribe_rescaled c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female 
estat esize

xtmixed c_trust_outvsingroup  || School_ID:, variance
regress c_trust_outvsingroup c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female 
estat esize

xtmixed c_Trust_people_rescaled  || School_ID:, variance
regress c_Trust_people_rescaled c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female 
estat esize

xtmixed instit_trust  || School_ID:, variance
regress instit_trust c.Div_exposure##c.Pol_exposure c_Friends_ethnic SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity  Mixed_Ethnicity Female
estat esize


*separate attitudinal items
xtmixed Ethnic_Lazier c.Div_exposure Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani  Other_Ethnicity Age Female || School_ID:, variance
estimates store A1
xtmixed Ethnic_equally_smart c.Div_exposure Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store A2
xtmixed Ethnic_more_violent c.Div_exposure Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store A3
xtmixed Ethnic_equally_honest c.Div_exposure Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store A4

xtmixed Ethnic_teacher c.Div_exposure Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B1
xtmixed Ethnic_boss c.Div_exposure Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B2
xtmixed Ethnic_marriage c.Div_exposure Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B3
xtmixed Ethnic_vote c.Div_exposure Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B4

set scheme s1mono
coefplot A1, bylabel(Stereotype: laziness (N)) keep(*: Div_exposure) ///
|| A2, bylabel(Stereotype: intelligence (P)) keep(*: Div_exposure) ///
|| A3, bylabel(Stereotype: violence (N)) keep(*: Div_exposure) ///
|| A4, bylabel (Stereotype: honesty (P))keep(*: Div_exposure) ///
|| B1, bylabel (Social Distance teacher (N))keep(*: Div_exposure) ///
|| B2, bylabel (Social Distance boss (P))keep(*: Div_exposure) ///
|| B3, bylabel (Social Distance marriage (N))keep(*: Div_exposure) ///
|| B4, bylabel (Social Distance vote (N))keep(*: Div_exposure) ///
bycoefs byopts(xrescale) xline(0) subtitle(Diversity exposure) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)

xtmixed Ethnic_Lazier c.Div_exposure c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani  Other_Ethnicity Age Female || School_ID:, variance
estimates store A1
xtmixed Ethnic_equally_smart c.Div_exposure c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store A2
xtmixed Ethnic_more_violent c.Div_exposure c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store A3
xtmixed Ethnic_equally_honest c.Div_exposure c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store A4

xtmixed Ethnic_teacher c.Div_exposure c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B1
xtmixed Ethnic_boss c.Div_exposure c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B2
xtmixed Ethnic_marriage c.Div_exposure c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B3
xtmixed Ethnic_vote c.Div_exposure c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B4

set scheme s1mono
coefplot A1, bylabel(Stereotype: laziness (N)) keep(*: Div_exposure c_Friends_ethnic) ///
|| A2, bylabel(Stereotype: intelligence (P)) keep(*: Div_exposure c_Friends_ethnic) ///
|| A3, bylabel(Stereotype: violence (N)) keep(*: Div_exposure c_Friends_ethnic) ///
|| A4, bylabel (Stereotype: honesty (P))keep(*: Div_exposure c_Friends_ethnic) ///
|| B1, bylabel (Social Distance teacher (N))keep(*: Div_exposure c_Friends_ethnic) ///
|| B2, bylabel (Social Distance boss (P))keep(*: Div_exposure c_Friends_ethnic) ///
|| B3, bylabel (Social Distance marriage (N))keep(*: Div_exposure c_Friends_ethnic) ///
|| B4, bylabel (Social Distance vote (N))keep(*: Div_exposure c_Friends_ethnic) ///
bycoefs xline(0) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)


xtmixed Ethnic_Lazier c.Div_exposure##c.Pol_exposure  c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani  Other_Ethnicity Age Female || School_ID:, variance
estimates store A1
xtmixed Ethnic_equally_smart c.Div_exposure##c.Pol_exposure  c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store A2
xtmixed Ethnic_more_violent c.Div_exposure##c.Pol_exposure  c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store A3
xtmixed Ethnic_equally_honest c.Div_exposure##c.Pol_exposure  c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store A4

xtmixed Ethnic_teacher c.Div_exposure##c.Pol_exposure  c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B1
xtmixed Ethnic_boss c.Div_exposure##c.Pol_exposure  c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B2
xtmixed Ethnic_marriage c.Div_exposure##c.Pol_exposure  c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B3
xtmixed Ethnic_vote c.Div_exposure##c.Pol_exposure  c_Friends_ethnic Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female || School_ID:, variance
estimates store B4

set scheme s1mono
coefplot A1, bylabel(Stereotype: laziness (N)) drop(_cons Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female) ///
|| A2, bylabel(Stereotype: intelligence (P)) drop(_cons Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female) ///
|| A3, bylabel(Stereotype: violence (N)) drop(_cons Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female) ///
|| A4, bylabel (Stereotype: honesty (P)) drop(_cons Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female) ///
|| B1, bylabel (Social Distance teacher (N)) drop(_cons Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female) ///
|| B2, bylabel (Social Distance boss (P)) drop(_cons Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female) ///
|| B3, bylabel (Social Distance marriage (N)) drop(_cons Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female)  ///
|| B4, bylabel (Social Distance vote (N)) drop(_cons Mixed_Ethnicity SES Current_living_conditions Living_compared Igbo Hausa_Fulani Other_Ethnicity Age Female) ///
bycoefs xline(0) subtitle(, size(small)) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)

summ RELF_school Religions_school Religions_neighbourhood
factor RELF_school Religions_school Religions_neighbourhood, pcf
predict RDiv_exposure
label variable RDiv_exposure "Religious diversity exposure"

summ Religion_teacher Religion_boss Religion_marriage Religion_vote
factor Religion_teacher Religion_boss Religion_marriage Religion_vote, pcf
predict factor_Rdistance
gen RSocialDistance = -1*factor_Rdistance
label variable RSocialDistance "Reduced religious social distance"

label variable c_Friends_religion "cross-religion friendship"

*regression analyses
xtmixed RSocialDistance c.RDiv_exposure SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store B1
xtmixed RSocialDistance c.RDiv_exposure c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store B2
xtmixed RSocialDistance c.RDiv_exposure##c.Pol_exposure c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store B3

xtmixed Trust_other_rel_rescaled c.RDiv_exposure SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store C1
xtmixed Trust_other_rel_rescaled c.RDiv_exposure c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store C2
xtmixed Trust_other_rel_rescaled c.RDiv_exposure##c.c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store C3
xtmixed Trust_other_rel_rescaled c.RDiv_exposure##c.Pol_exposure c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store C4

xtmixed Trust_own_rel_rescaled c.RDiv_exposure SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity Mixed_Ethnicity Female || School_ID:, variance
estimates store D1
xtmixed Trust_own_rel_rescaled c.RDiv_exposure c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store D2
xtmixed Trust_own_rel_rescaled c.RDiv_exposure##c.c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store D3
xtmixed Trust_own_rel_rescaled c.RDiv_exposure##c.Pol_exposure c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store D4

xtmixed c_Trust_people_rescaled c.RDiv_exposure SES Current_living_conditions Living_compared Age Igbo Hausa_Fulani Other_Ethnicity Mixed_Ethnicity Female || School_ID:, variance
estimates store E1
xtmixed c_Trust_people_rescaled c.RDiv_exposure c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store E2
xtmixed c_Trust_people_rescaled c.RDiv_exposure##c.c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store E3
xtmixed c_Trust_people_rescaled c.RDiv_exposure##c.Pol_exposure c_Friends_religion SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female || School_ID:, variance
estimates store E4

set scheme s1mono
coefplot B1, bylabel (Reduced Religious Distance) keep(RDiv_exposure) ///
|| C1, bylabel (Religious outgroup trust) keep(RDiv_exposure) ///
|| D1, bylabel (Religious ingroup trust)keep (RDiv_exposure) ///
|| E1, bylabel (General trust) keep(RDiv_exposure) ///
bycoefs byopts(xrescale) xline(0) subtitle("Exposure to religious diversity",size(small)) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)

coefplot  B2, bylabel (Reduced Religious Social Distance) keep(RDiv_exposure c_Friends_religion) ///
|| C2, bylabel (Religious outgroup trust) keep(RDiv_exposure c_Friends_religion) ///
|| D2, bylabel (Religious ingroup trust)keep (RDiv_exposure c_Friends_religion) ///
|| E2, bylabel (General trust) keep(RDiv_exposure c_Friends_religion) ///
bycoefs  xline(0) subtitle(,size(small)) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)

coefplot C3, bylabel (Religious outgroup trust) drop(SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female _cons) ///
|| D3, bylabel (Religious ingroup trust) drop(SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female _cons)  ///
|| E3, bylabel (General trust) drop(SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female _cons)  ///
bycoefs xline(0) subtitle(,size(vsmall)) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)

coefplot  B3, bylabel (Reduced Religious Social Distance) drop(SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female _cons) ///
|| C4, bylabel (Religious outgroup trust) drop(SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female _cons) ///
|| D4, bylabel (Religious ingroup trust) drop(SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female _cons) ///
|| E4, bylabel (General trust) drop(SES Current_living_conditions Living_compared Age Christian Mixed_Religion Female _cons) ///
bycoefs  xline(0) subtitle(,size(vsmall)) ylabel(,labsize(small)) xlabel(,labsize(small)) msize(small)
